******************************************************************************************************************		
**** Multilevel regressions: Results using alternatives measures of nationalist attitudes (Appendix C.5) *********
******************************************************************************************************************
clear
use "BHPS_merged.dta"

do "ML programs to add model statistics.do"

global tradevar "real_gr_imp_CH_d3_nl"

* create deltas of single items 
	gen D_nat2=nat2-L3.nat2
	gen D_nat4=nat4-L3.nat4
	gen D_nat6=nat6-L3.nat6

*** Mean of nat2, nat4 & nat6 (reversed)
	gen nat6_rev=-nat6+4
	gen natatt_mean=(nat2+nat4+nat6_rev)/3
	gen D3_natatt_mean=natatt_mean-L3.natatt_mean

	* regression			
	mixed D3_natatt_mean L3.D3_natatt_mean  ///
		$tradevar ///
		emplsh_manufact_1998 pop_sharenonUK pop_sharenonUK_d_nat ///
		$controls i.ID_NUTS1xYear  ///
		if (year==2008 | year==2005 | year==2002) ///
		|| ID_NUTS3: || ID_NUTS3xYear: || ID_lad13xyear: , stddeviations

		add_scalars_mixed_3level
						
		eststo NAT_mean
	
*** Single items

	* Single item: I would rather be a citizen of Britain than of any other country in the world
	mixed D_nat2 L3.nat2  ///
		$tradevar ///
		emplsh_manufact_1998 pop_sharenonUK pop_sharenonUK_d_nat ///
		$controls i.ID_NUTS1xYear  ///
		if (year==2008 | year==2005 | year==2002) ///
		|| ID_NUTS3: || ID_NUTS3xYear: || ID_lad13xyear: , stddeviations

		add_scalars_mixed_3level

		eststo NAT_single1

	* Single item: People in Britain are too ready to criticize their country								
	mixed D_nat4 L3.nat4 ///
		$tradevar ///
		emplsh_manufact_1998 pop_sharenonUK pop_sharenonUK_d_nat ///
		$controls i.ID_NUTS1xYear  ///
		if (year==2008 | year==2005 | year==2002) ///
		|| ID_NUTS3: || ID_NUTS3xYear: || ID_lad13xyear: , stddeviations

		add_scalars_mixed_3level
		
		eststo NAT_single2
	
	* Single item: Cooperate with other countries even if it means giving up some independence
	mixed D_nat6 L3.nat6  ///
		$tradevar ///
		emplsh_manufact_1998 pop_sharenonUK pop_sharenonUK_d_nat ///
		$controls i.ID_NUTS1xYear  ///
		if (year==2008 | year==2005 | year==2002) ///
		|| ID_NUTS3: || ID_NUTS3xYear: || ID_lad13xyear: , stddeviations

		add_scalars_mixed_3level
		
		eststo NAT_single3

*** Alternative factors

	* nat2 & nat4
	polychoric nat2 nat4
	display r(sum_w)
	global N = r(sum_w)
	matrix r = r(R)
	factormat r, n($N) pcf
	predict nationalism_narrow		
	
	gen D3_nationalism_narrow=nationalism_narrow-L3.nationalism_narrow

	* regression			
	mixed D3_nationalism_narrow L3.nationalism_narrow  ///
		$tradevar ///
		emplsh_manufact_1998 pop_sharenonUK pop_sharenonUK_d_nat ///
		$controls i.ID_NUTS1xYear  ///
		if (year==2008 | year==2005 | year==2002) ///
		|| ID_NUTS3: || ID_NUTS3xYear: || ID_lad13xyear: , stddeviations

		add_scalars_mixed_3level
						
		eststo NAT_altfac1
					

	* nat2, nat4, nat6 & nat5
	polychoric nat2 nat4 nat6 nat5
	display r(sum_w)
	global N = r(sum_w)
	matrix r = r(R)
	factormat r, n($N) pcf
	predict nationalism_broader	
	
	gen D3_nationalism_broader=nationalism_broader-L3.nationalism_broader

	* regression			
	mixed D3_nationalism_broader L3.nationalism_broader  ///
		$tradevar ///
		emplsh_manufact_1998 pop_sharenonUK pop_sharenonUK_d_nat ///
		$controls i.ID_NUTS1xYear  ///
		if (year==2008 | year==2005 | year==2002) ///
		|| ID_NUTS3: || ID_NUTS3xYear: || ID_lad13xyear: , stddeviations

		add_scalars_mixed_3level
						
		eststo NAT_altfac2	
								
	
	* nat2, nat4, nat6 & nat1
	polychoric nat2 nat4 nat6 nat1
	display r(sum_w)
	global N = r(sum_w)
	matrix r = r(R)
	factormat r, n($N) pcf
	predict nationalism_broader3	
	
	gen D3_nationalism_broader3=nationalism_broader3-L3.nationalism_broader3

	* regression			
	mixed D3_nationalism_broader3 L3.nationalism_broader3 ///
		$tradevar ///
		emplsh_manufact_1998 pop_sharenonUK pop_sharenonUK_d_nat ///
		$controls i.ID_NUTS1xYear  ///
		if (year==2008 | year==2005 | year==2002) ///
		|| ID_NUTS3: || ID_NUTS3xYear: || ID_lad13xyear: , stddeviations

		add_scalars_mixed_3level
						
		eststo NAT_altfac3		

	
	* nat2, nat4, nat6, nat5 & nat1
	polychoric nat2 nat4 nat6 nat5 nat1
	display r(sum_w)
	global N = r(sum_w)
	matrix r = r(R)
	factormat r, n($N) pcf
	predict nationalism_broader2	
	
	gen D3_nationalism_broader2=nationalism_broader2-L3.nationalism_broader2

	* regression			
	mixed D3_nationalism_broader2 L3.nationalism_broader2 ///
		$tradevar ///
		emplsh_manufact_1998 pop_sharenonUK pop_sharenonUK_d_nat ///
		$controls i.ID_NUTS1xYear  ///
		if (year==2008 | year==2005 | year==2002) ///
		|| ID_NUTS3: || ID_NUTS3xYear: || ID_lad13xyear: , stddeviations

		add_scalars_mixed_3level
						
		eststo NAT_altfac4			